package com.ai.controller.made;


import com.ai.annotation.EnterPathParamLog;
import com.ai.common.CommonResponse;
import com.ai.entity.alarm.RecordAlarmBO;
import com.ai.entity.alarm.RecordAlarmPage;
import com.ai.model.page.CoalMaintenancePage;
import com.ai.model.page.CoalRoutingInspectionPage;
import com.ai.service.made.ICoalMaintenanceAlarmRecordService;
import com.ai.service.made.ICoalRoutingInspectionAlarmRecordService;
import com.ai.service.made.RecordAlarmService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 算法识别记录
 * @author Mr.Chen
 * @since 2020-06-19
 */
@RestController
@RequestMapping("/recordAlarm")
@Slf4j
public class RecordAlarmController {

    @Resource
    RecordAlarmService recordAlarmService;


    @Resource
    private ICoalRoutingInspectionAlarmRecordService iCoalRoutingInspectionAlarmRecordService;

    @Resource
    private ICoalMaintenanceAlarmRecordService maintenanceAlarmRecordService;

    /**
     *   识别记录    分页查询，列表查询
     *
     *   根据不同的  functionType 值 查找到不同识别记录
     * @param page
     * @return
     */
    @ApiOperation("分页查询")
    @PostMapping("list")
    @EnterPathParamLog
    public CommonResponse selectByPage(@RequestBody RecordAlarmPage page) {
        CommonResponse resultData = recordAlarmService.selectByPage(page);
        return resultData;
    }


    @ApiOperation("巡检分页查询")
    @PostMapping("coalRoutingInspectionList")
    @EnterPathParamLog
    public CommonResponse coalRoutingInspectionList(@RequestBody CoalRoutingInspectionPage coalRoutingInspectionPage) {

        return iCoalRoutingInspectionAlarmRecordService.coalRoutingInspectionList(coalRoutingInspectionPage);

    }


    @ApiOperation("单轨吊检修分页查询")
    @PostMapping("coalMaintenanceList")
    @EnterPathParamLog
    public CommonResponse coalMaintenanceList(@RequestBody CoalMaintenancePage coalMaintenancePage) {

        return maintenanceAlarmRecordService.coalMaintenanceList(coalMaintenancePage);

    }

    /**
     * 标记是否误报
     *
     * @param recordAlarmBO
     * @return
     */
    @ApiOperation("标记是否误报")
    @PostMapping("signError")
    @EnterPathParamLog
    public CommonResponse signError(@RequestBody RecordAlarmBO recordAlarmBO) {
        CommonResponse resultData = recordAlarmService.signError(recordAlarmBO);
        return resultData;
    }

    @ApiOperation("批量标记是否误报")
    @PostMapping("batchSignError")
    @EnterPathParamLog
    public CommonResponse batchSignError(@RequestBody List<RecordAlarmBO> recordAlarmBOList) {
        CommonResponse resultData = recordAlarmService.batchSignError(recordAlarmBOList);
        return resultData;
    }

    @PostMapping("/exportRecordExcel")
    public void exportRecordExcel() {
        // 设置文件导出的路径
        recordAlarmService.exportRecordExcel();
    }

    @ApiOperation("告警信息条件导出")
    @PostMapping("alarmExportExel")
    public void alarmExportExel(@RequestBody RecordAlarmPage page, HttpServletResponse response ) {
        recordAlarmService.alarmExportExel(page,response);
    }

    @ApiOperation("单轨吊检修条件导出")
    @PostMapping("coalMaintenanceAlarmExportExel")
    public void coalMaintenanceAlarmExportExel(@RequestBody RecordAlarmPage page, HttpServletResponse response ) {
        recordAlarmService.coalMaintenanceAlarmExportExel(page,response);
    }


    @ApiOperation("获取最新的10条识别记录")
    @PostMapping("latestRecord")
    @EnterPathParamLog
    public CommonResponse latestRecord(){
        return recordAlarmService.latestRecord();
    }

}

